<ui:composition template="/WEB-INF/templates/main-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="sidebar">
		<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>
	<ui:define name="content">
		<h:form id="viewTimesheetsForm">
			<h:outputText value="Employees Time Sheet LOG - SECURITY DESK"
				styleClass="outputTextTitle" />
			<p:growl id="growl" />
			<p:ajaxStatus onstart="statusDialog.show();"
				onsuccess="statusDialog.hide();" />

			<p:dialog modal="true" widgetVar="statusDialog" showHeader="false"
				draggable="false" closable="false">
				<p:graphicImage
					value="/resources/styles/images/ajax-loading-bar.gif" />
			</p:dialog>

			<h:panelGrid columns="2">
				<h:panelGroup>

					<h:outputText value="Select Date:" />
					<br />
					<p:calendar value="#{securityInterfaceBean.timesheetDate}"
						navigator="true" pattern="dd-MMM-yyyy" maxlength="11" yearRange="c-1:c+1" readOnlyInputText="true">
						<p:ajax event="dateSelect" listener="#{securityInterfaceBean.dateChanged}" update="@form"></p:ajax>	
					</p:calendar>
					<h:inputHidden value="#{securityInterfaceBean.security}" />
				</h:panelGroup>
				<h:panelGroup>
					<h:outputText value="Security Person Name:" />
					<br />
					<p:inputText
						value="#{securityInterfaceBean.securityPerson}"></p:inputText>

				</h:panelGroup>


			</h:panelGrid>




			<h:panelGrid>


				<p:dataTable id="timesheetDetailsTable" paginator="true" rows="10"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15"
					value="#{securityInterfaceBean.timesheetDetails}"
					var="row">
					<p:column style="width: 90px;">
						<f:facet name="header">
							<h:outputText value="Employee Code" />
						</f:facet>
						<h:outputText value="#{row.timesheet.employee.employeeCode}" />
					</p:column>
					<p:column style="width: 290px;">
						<f:facet name="header">
							<h:outputText value="Employee Name" />
						</f:facet>
						<h:outputText value="#{row.timesheet.employee.firstName} #{row.timesheet.employee.lastName}" />
					</p:column>

					<p:column style="width: 90px;">
						<f:facet name="header">
							<h:outputText value="Module" />
						</f:facet>
						<h:outputText value="#{row.timesheet.employee.moduleName}" />
					</p:column>

					<p:column style="width: 2px">
						<f:facet name="header">
							<h:outputText value="In Time" />
						</f:facet>
						<p:inputMask value="#{row.inTimeString}" style="width: 50px;" disabled="#{row.timesheet.timesheetStatus eq 'TO BE APPROVED' or row.timesheet.timesheetStatus eq 'APPROVED'}"
							mask="99:99"></p:inputMask>
					</p:column>

					<p:column style="width: 2px">
						<f:facet name="header">
							<h:outputText value="Out Time" />
						</f:facet>
						<p:inputMask value="#{row.outTimeString}" style="width: 50px;" disabled="#{row.timesheet.timesheetStatus eq 'TO BE APPROVED' or row.timesheet.timesheetStatus eq 'APPROVED'}"
							mask="99:99"></p:inputMask>
					</p:column>
					<p:column style="width: 2px">
						<f:facet name="header">
							<h:outputText value="Last updated by" />
						</f:facet>
						<h:outputText
						value="#{row.securityPerson}" />
							
					</p:column>

				</p:dataTable>

			</h:panelGrid>
			<h:panelGrid columns="1">
				<p:commandButton value="Save Employees Log Data"
					actionListener="#{securityInterfaceBean.saveEmployeeLogs}"
					update="growl"></p:commandButton>
			</h:panelGrid>


		</h:form>
	</ui:define>
</ui:composition>

